clear; clc; close all

p = 15;
n = 1000;

x = rand(n,p);
lrcols = find(rand(1,p) < 0.5);
x(:,lrcols) = rand(n,length(lrcols)) < 0.5;

y = zeros(n,1);
coeff = zeros(n,1);
for i = 1:p,
    coeff(i) = round(10*(rand-0.5));
    y = y + coeff(i)*x(:,i);
end

y = round(y + 15 + rand(n,1));
fname = 'C:\Users\Mittal\Documents\Work\Code\imputation\C\codebase\CCD\Release\test-LR-BBR.txt';
fp = fopen(fname,'w');
data = [y x];
for i = 1:n,
    fprintf(fp,'%d',round(rand));
    for j = 2:size(data,2),
        if(0)
            fprintf(fp,' %d:NULL',j-1);
        else
            if(data(i,j) ~= 0)
                fprintf(fp,' %d:%f',j-1,data(i,j));
            end
        end
    end
    fprintf(fp,'\n');
end
% dlmwrite(fname,data,'delimiter',',','-append');

fclose(fp);